package com.zhiyou.impl;

import com.zhiyou.Dao.UserDao;
import com.zhiyou.pojo.User;
import com.zhiyou.util.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class UserImpl implements UserDao {
    public List<User> getAll() {
        return null;
    }

    public void addUser(User user) {

    }

    public void deleteUserById(User user) {
        SqlSession sqlSession = MyBatisUtil.getSqlSessionFactory().openSession();
        try {
            sqlSession.getMapper(UserDao.class).addUser(user);
            sqlSession.commit();
        }catch (Exception e){
            sqlSession.rollback();
            e.printStackTrace();
        }
        sqlSession.close();
    }

    public void updateUserByid(User user) {

    }
}
